package cn.hzking.gjmall.utils;

import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.widget.TextView;

import cn.hzking.gjmall.R;

/**
 * Created by Administrator on 2018/3/7.
 */

public class IconTextSpanUtils {

    public static void setText(Context context , String text, String iconText, TextView textView){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("顶");
        stringBuilder.append(text);
        IconTextSpan topSpan = new IconTextSpan(context, R.color.red, iconText);
        SpannableString spannableString = new SpannableString(stringBuilder.toString());
        spannableString.setSpan(topSpan, 0,  1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(spannableString);
    };
    public static void setText(Context context , String text, String iconText, TextView textView,int color){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("顶");
        stringBuilder.append(text);
        IconTextSpan topSpan = new IconTextSpan(context, color, iconText);
        SpannableString spannableString = new SpannableString(stringBuilder.toString());
        spannableString.setSpan(topSpan, 0,  1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(spannableString);
    };
}
